/**
 * @Author: 焦质晔
 * @Date: 2019/6/20
 * @Last Modified by: mikey.zhaopeng
 * @Last Modified time: 2019-12-15 15:21:28
 */
import axios from '@/api/fetch';
import SERVER from '@/api/server';

// 列表查询
export const getList = params => axios.get(`${SERVER.WHOLESALES}/retailSet/getInfo`, { params });
// 新增
export const addSave = params => axios.post(`${SERVER.WHOLESALES}/retailSet/retailSetSave`, params);
// 编辑
export const emitSave = params => axios.put(`${SERVER.BASEDATA}/vehicleProduct/dealer/${params.colorId}`, params);
// 导入经销商
export const importDealer = params => axios.post(`${SERVER.WHOLESALES}/retailSetDealer/dealerImportFromExcel`, params);

export const importProduct = params => axios.post(`${SERVER.WHOLESALES}/retailSetDealer/productImportFromExcel`, params);

// 查询导入经销商
export const getdealerList = params => axios.get(`${SERVER.WHOLESALES}/retailSetDealer/getInfo`, { params });

export const getListById = id => axios.get(`${SERVER.WHOLESALES}/retailSet/getRetailSetById`, { params: { setId: id } });

// 查询导入经销商
export const getProductList = params => axios.get(`${SERVER.WHOLESALES}/retailSetProduct/getInfo`, { params });

//删除已设置经销商
export const delDealerList = ids => axios.delete(`${SERVER.WHOLESALES}/retailSetDealer/delete/${ids}`, { params: { ids: ids } });
//删除已设置物料
export const delProductList = ids => axios.delete(`${SERVER.WHOLESALES}/retailSetProduct/delete/${ids}`, { params: { ids: ids } });

// export const downloadDealer = (params) => axios.post(`${SERVER.WHOLESALES}/retailSetDealer/dealerImportFromExcel`, params,{responseType: 'blob'})
//导入后查询
export const importQuery = params => axios.get(`${SERVER.WHOLESALES}/retailSetDealer/getInfo`, { params });
// 查询所有员工
export const getDealerUser = params => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/users/getDealerUser`);

//导出模版
export const downloadDealer = params => {
  const url = `${SERVER.WHOLESALES}/retailSetDealer/export`;
  return axios({
    url,
    method: 'get',
    responseType: 'blob'
  });
};

//导出模版
export const downloadProduct = params => {
  const url = `${SERVER.WHOLESALES}/retailSetProduct/export`;
  return axios({
    url,
    method: 'get',
    responseType: 'blob'
  });
};

export const exporturl = params => axios.post(`/api/cmscloud.excel/downloadExcel/exportExcel/${params.CODE}`, params);
